#1.1 准备工作

api_secret = M7WLF7GIZ2bqhviCNeItw_ZR4pDYg_gP
api_key = fMCHY1PqQTQLWMxM787KAdNjm3AibZeR

#1.2 FaceSet Create

import requests,json

display_name = "网新一班人脸集合"
outer_id = "00001"
user_data = "52人，20男生，32女生"

CreateFace_Url = "https://api-cn.faceplusplus.com/facepp/v3/faceset/create"
payload = {
    'api_key': api_key,
    'api_secret': api_secret,
    'display_name':display_name,
    'outer_id':outer_id,
    'user_data':user_data
}

r = requests.post(CreateFace_Url, params=payload)

r.json()

#1.3 FaceSet GetDetail

GetDetail_Url = "https://api-cn.faceplusplus.com/facepp/v3/faceset/getdetail"

payload = {
    'api_key': api_key,
    'api_secret': api_secret,
    'outer_id':outer_id,
}

r = requests.post(GetDetail_Url,params=payload)

r.json()

#1.4 FaceSet AddFace

AddFace_url = " https://api-cn.faceplusplus.com/facepp/v3/faceset/addface"

payload = {
    'api_key': api_key,
    'api_secret': api_secret,
    'faceset_token':'37071d95016c1b2d81591a6f0c1681f2',
    'face_tokens':'b0407b9e803ebd39d511cd7956fd5bf5',
}

r = requests.post(AddFace_url,params=payload)

r.json()

#1.5 FaceSet RemoveFace

RemoveFace_url = " https://api-cn.faceplusplus.com/facepp/v3/faceset/removeface"

payload = {
    'api_key': api_key,
    'api_secret': api_secret,
    'faceset_token':'37071d95016c1b2d81591a6f0c1681f2',
    'face_tokens':'b0407b9e803ebd39d511cd7956fd5bf5',
}

r = requests.post(RemoveFace_url,params=payload)

r.json()

#1.6 FaceSet Update

Update_url = "https://api-cn.faceplusplus.com/facepp/v3/faceset/update"

payload = {
    'api_key': api_key,
    'api_secret': api_secret,
    'faceset_token':'37071d95016c1b2d81591a6f0c1681f2',
    'user_data':"53人，21男生，32女生",
}

r = requests.post(Update_url,params=payload)

r.json()

#1.7 Compare Face
#1.7.1 方案1:直接对比

Compare_url = "https://api-cn.faceplusplus.com/facepp/v3/compare"

payload ={
    'api_key': api_key,
    'api_secret': api_secret,
    'image_url1':liudehua01,
    'image_url2':wangzulan
}

r = requests.post(Compare_url,params=payload)

r.json()

#1.7.2 方案2:与人脸集合进行对比
#1.7.2.1 面部检测(获取face_token)

Detect_url = 'https://api-cn.faceplusplus.com/facepp/v3/detect' 
img_url = liudehua01

payload = {
    "image_url":img_url,
    'api_key': api_key,
    'api_secret': api_secret,
    'return_attributes':'gender,age,smiling,emotion', 
}

r = requests.post(Detect_url,params=payload)

r.json()